#ifndef CALENDARITEM_H
#define CALENDARITEM_H

#include <QWidget>
#include <QDate>
#include <QPainter>
#include <QPaintEvent>

class CalendarItem : public QWidget
{
    Q_OBJECT

    Q_ENUMS(SelectType)
    Q_PROPERTY(bool select READ getSelect WRITE setSelect)
    Q_PROPERTY(bool showLunar READ getShowLunar WRITE setShowLunar)
    Q_PROPERTY(QString bgImage READ getBgImage WRITE setBgImage)
    Q_PROPERTY(SelectType selectType READ getSelectType WRITE setSelectType)

    Q_PROPERTY(QDate date READ getDate WRITE setDate)
    Q_PROPERTY(QString lunar READ getLunar WRITE setLunar)
    Q_PROPERTY(DayType dayType READ getDayType WRITE setDayType)

    Q_PROPERTY(QColor borderColor READ getBorderColor WRITE setBorderColor)
    Q_PROPERTY(QColor weekColor READ getWeekColor WRITE setWeekColor)
    Q_PROPERTY(QColor superColor READ getSuperColor WRITE setSuperColor)
    Q_PROPERTY(QColor lunarColor READ getLunarColor WRITE setLunarColor)

    Q_PROPERTY(QColor currentTextColor READ getCurrentTextColor WRITE setCurrentTextColor)
    Q_PROPERTY(QColor otherTextColor READ getOtherTextColor WRITE setOtherTextColor)
    Q_PROPERTY(QColor selectTextColor READ getSelectTextColor WRITE setSelectTextColor)
    Q_PROPERTY(QColor hoverTextColor READ getHoverTextColor WRITE setHoverTextColor)

    Q_PROPERTY(QColor currentLunarColor READ getCurrentLunarColor WRITE setCurrentLunarColor)
    Q_PROPERTY(QColor otherLunarColor READ getOtherLunarColor WRITE setOtherLunarColor)
    Q_PROPERTY(QColor selectLunarColor READ getSelectLunarColor WRITE setSelectLunarColor)
    Q_PROPERTY(QColor hoverLunarColor READ getHoverLunarColor WRITE setHoverLunarColor)

    Q_PROPERTY(QColor currentBgColor READ getCurrentBgColor WRITE setCurrentBgColor)
    Q_PROPERTY(QColor otherBgColor READ getOtherBgColor WRITE setOtherBgColor)
    Q_PROPERTY(QColor selectBgColor READ getSelectBgColor WRITE setSelectBgColor)
    Q_PROPERTY(QColor hoverBgColor READ getHoverBgColor WRITE setHoverBgColor)
public:
    explicit CalendarItem(QWidget *parent=0);

    enum DayType
    {
        DayType_MonthPre = 0,
        DayType_MonthNext = 1,
        DayType_MonthCurrent = 2,
        DayType_WeekEnd = 3,
    };

    enum SelectType
    {
        SelectType_Rect = 0,
        SelectType_Circle = 1,
        SelectType_Triangle = 2,
        SelectType_Image = 3,
    };


    bool hover;
    bool pressed;
    bool select;
    bool showLunar;
    QStringList listDayName;
    QString bgImage;
    SelectType selectType;
    QDate date;
    QString lunar;
    DayType dayType;

    QColor borderColor;
    QColor weekColor;
    QColor superColor;
    QColor lunarColor;
    QColor currentTextColor;
    QColor otherTextColor;
    QColor selectTextColor;
    QColor hoverTextColor;
    QColor currentLunarColor;
    QColor otherLunarColor;
    QColor selectLunarColor;
    QColor hoverLunarColor;
    QColor currentBgColor;
    QColor otherBgColor;
    QColor selectBgColor;
    QColor hoverBgColor;

    void setDate(const QDate &date, const QString &lunar, const DayType &dayType);
    void setSelect(bool index);
    void paintEvent(QPaintEvent *);
    void drawBg(QPainter *);
    void drawBgCurrent(QPainter *painter, QColor);
    void drawDay(QPainter *);
    void drawLunar(QPainter *);
    void enterEvent(QEvent *event);
    void leaveEvent(QEvent *event);
    void mousePressEvent(QMouseEvent *);
    void mouseReleaseEvent(QMouseEvent *);


    bool getSelect(){return this->select;}
    bool getShowLunar(){return this->showLunar;}
    QString getBgImage(){return this->bgImage;}
    SelectType getSelectType(){return this->selectType;}
    QDate getDate(){return this->date;}
    QString getLunar(){return this->lunar;}
    DayType getDayType(){return this->dayType;}
    QColor getBorderColor(){return this->borderColor;}
    QColor getWeekColor(){return this->weekColor;}
    QColor getSuperColor(){return this->superColor;}
    QColor getLunarColor(){return this->lunarColor;}
    QColor getCurrentTextColor(){return this->currentTextColor;}
    QColor getOtherTextColor(){return this->otherTextColor;}
    QColor getSelectTextColor(){return this->selectTextColor;}
    QColor getHoverTextColor(){return this->hoverTextColor;}
    QColor getCurrentLunarColor(){return this->currentLunarColor;}
    QColor getOtherLunarColor(){return this->otherLunarColor;}
    QColor getSelectLunarColor(){return this->selectLunarColor;}
    QColor getHoverLunarColor(){return this->hoverLunarColor;}
    QColor getCurrentBgColor(){return this->currentBgColor;}
    QColor getOtherBgColor(){return this->otherBgColor;}
    QColor getSelectBgColor(){return this->selectBgColor;}
    QColor getHoverBgColor(){return this->hoverBgColor;}

    void setShowLunar(bool showLunar){this->showLunar = showLunar;}
    void setBgImage(QString bgImage){this->bgImage = bgImage;}
    void setSelectType(SelectType selectType){this->selectType = selectType;}
    void setDate(QDate date){this->date = date;}
    void setLunar(QString lunar){this->lunar = lunar;}
    void setDayType(DayType dayType){this->dayType = dayType;}
    void setBorderColor(QColor borderColor){this->borderColor = borderColor;}
    void setWeekColor(QColor weekColor){this->weekColor = weekColor;}
    void setSupperColor(QColor supperColor){this->superColor = supperColor;}
    void setLunarColor(QColor lunarColor){this->lunarColor = lunarColor;}
    void setCurrentTextColor(QColor currentTextColor){this->currentTextColor = currentTextColor;}
    void setOtherTextColor(QColor otherTextColor){this->otherTextColor = otherTextColor;}
    void setSelectTextColor(QColor selectTextColor){this->selectTextColor = selectTextColor;}
    void setHoverTextColor(QColor hoverTextColor){this->hoverTextColor = hoverTextColor;}
    void setCurrentLunarColor(QColor currentLunarColor){this->currentLunarColor = currentLunarColor;}
    void setOtherLunarColor(QColor otherLunarColor){this->otherLunarColor = otherLunarColor;}
    void setSelectLunarColor(QColor selectLunarColor){this->selectLunarColor = selectLunarColor;}
    void setHoverLunarColor(QColor hoverLunarColor){this->hoverLunarColor = hoverLunarColor;}
    void setCurrentBgColor(QColor currentBgColor){this->currentBgColor = currentBgColor;}
    void setOtherBgColor(QColor otherBgColor){this->otherBgColor = otherBgColor;}
    void setSelectBgColor(QColor selectBgColor){this->selectBgColor = selectBgColor;}
    void setHoverBgColor(QColor hoverBgColor){this->hoverBgColor = hoverBgColor;}
    void setSuperColor(QColor supperColor){this->superColor = supperColor;}

signals:
    void clicked( QDate date,  CalendarItem::DayType dayType);

};

#endif // CALENDARITEM_H
